#include <bits/stdc++.h>
using namespace std;

int arr[45][45];
int dx[8]={0,0,1,-1,1,1,-1,-1};
int dy[8]={1,-1,0,0,1,-1,1,-1};
int main(){
    int n,m;
    cin>>n>>m;
    while (m--){
        int x,y,nx,ny;
        cin>>x>>y;
        arr[x][y]=-1;
        for (int i = 0; i < 8; ++i) {
            nx=x+dx[i];
            ny=y+dy[i];
            if (arr[nx][ny]!=-1)
                ++arr[nx][ny];
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j)
            cout<<arr[i][j]<<' ';
        cout<<endl;
    }
    return 0;
}